{{addToMap . "ContentTitle" "监控点列表"}}

<div class="content">
<div class="box">
  <div class="box-header">
      <div class="pull-left">
        <a class="btn btn-info" data-toggle="tooltip" title="" href="/project/{{.Project.Id}}/tracing/create?listsubmenu={{$.SubMenu}}"><i class="fa fa-plus-square"></i> 新增</a>
      </div>
  </div>
  <div class="box-body">
    {{ $tracingIdNums := len .TracingIds }}
    {{if ne $tracingIdNums 0}}
    <table class="table table-bordered .table-hover">
        <thead>
            <tr>
                <th>ID</th>
                <th>监控点</th>
                <th>名称</th>
                <th>监控状态</th>
                <th>类型</th>
                <th>创建人</th>
                <th>最后报警时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {{ range .TracingIds }}
            {{ $tracing := index $.Tracings .}}
            {{ $lastWarningTime := index $.LastTracingWarningTimes .}}
            {{ $user := index $.Users $tracing.UserId}}
                <tr tracing-id="{{$tracing.Id}}">
                    <td>{{$tracing.Id}}</td>
                    <td>{{$tracing.Key}}</td>
                    <td>{{$tracing.Title}}</td>
                    <td>{{if eq $tracing.Status 10}}<font color="green">监控中</font>{{else}}停止{{end}}</td>
                    <td>{{if eq $tracing.Type 1}}直接触发{{else}}定时触发{{end}}</td>
                    <td><a tabindex="0" class="user-popover" data-toggle="popover" data-trigger="focus" role="button" data-placement="bottom" data-content="<b>联系电话:</b><br/>{{$user.Phone}}<br /><b>邮箱:</b><br /> {{$user.Email}}">{{$user.Name}}({{$user.Username}})</a></td>
                    <td>
                    {{if $lastWarningTime}}{{dateformat $lastWarningTime.CreateTime "2006-01-02 15:04:05"}}{{else}}暂无报警{{end}}
                    </td>
                    
                    <td>
                        <a href="/project/{{$.Project.Id}}/tracing/{{$tracing.Id}}/update?listsubmenu={{$.SubMenu}}">详情</a> | 
                        <a href="/project/{{$.Project.Id}}/tracing/{{$tracing.Id}}/warnings?listsubmenu={{$.SubMenu}}">查看报警记录</a> | 
                        <a href="#" class="tracing-del-btn">删除</a>
                    </td>
                </tr>
            {{ end }}
        </tbody>
    </table>
    {{else}}
    <p class="text-center lead">当前没有监控点 <a href="/project/{{$.Project.Id}}/tracing/create">马上添加</a></p>
    {{end}}
  </div>
    {{if and .paginator $tracingIdNums}}
    <div class="box-footer clearfix">
    <nav class="text-center">
    <ul class="pagination pagination-sm">
        {{if .paginator.HasPrev}}
        <li>
            <a href="{{.paginator.PageLinkFirst}}">首页</a>
        </li>
        <li>
            <a href="{{.paginator.PageLinkPrev}}">上一页</a>
        </li>
        {{else}}
        <li class="disabled">
            <a>首页</a>
        </li>
        <li class="disabled">
            <a>上一页</a>
        </li>
        {{end}}

        {{range $index, $page := .paginator.Pages}}
        <li{{if $.paginator.IsActive .}} class="active"{{end}}>
            <a href="{{$.paginator.PageLink $page}}">{{$page}}</a>
        </li>
        {{end}}
        {{if .paginator.HasNext}}
        <li>
            <a href="{{.paginator.PageLinkNext}}">下一页</a>
        </li>
        <li>
            <a href="{{.paginator.PageLinkLast}}">末页</a>
        </li>
        {{else}}
        <li class="disabled">
            <a>下一页</a>
        </li>
        <li class="disabled">
            <a>末页</a>
        </li>
        {{end}}
    </ul>
    </nav>
    </div>
    {{end}}
</div>
</div>
<script type="text/javascript">
$(function(){
$(".tracing-del-btn").on("click", function(e){
    e.preventDefault();
    if (!confirm("是否确认删除当前监控点?")) {
        return;
    }

    var tracingId = $(this).parent().parent().attr("tracing-id");
    if (!tracingId) {
        return;
    }

    $.post("/project/{{.Project.Id}}/tracing/ajaxDelTracing", {"id":tracingId}, function(repo){
        if (repo.code != 0) {
            alert("系统错误!");
            return
        }

        window.location.reload();
    }, "json");
});

$('.user-popover').popover({html:true});

});
</script>